# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=rime-quick
pkgver=0.0.0.20190120
_commit=3fe5911ba608cb2df1b6301b76ad1573bd482a76
pkgrel=1
pkgdesc="Quick input for rime"
arch=('loong64' 'x86_64')
url="https://github.com/rime/rime-quick"
license=('LGPL')
# dependency for reverse lookup
depends=('rime-luna-pinyin')
makedepends=('librime' 'rime-prelude' 'rime-essay')
source=("https://github.com/rime/rime-quick/archive/$_commit/rime-quick-$_commit.tar.gz")
sha512sums=('d693b90b76cf3dc72e84bb378e3b1a35850bed9edec45bfb321bf800561bd03fdf34ea41bc7ca8da53b02579de111da394a6aa4493989a4a4bde2eb0e2d7d485')

prepare() {
  cd $pkgname-$_commit
  # Link essentials
  for _f in $(pacman -Qql rime-prelude rime-essay | grep -v "/$"); do ln -sf $_f; done

  # Build binaries only for this package
  rm default.yaml
  cp /usr/share/rime-data/default.yaml ./
  sed -i -e '/- schema:/d' -e '/schema_list:/d' default.yaml
  echo "schema_list:" >> default.yaml
  ls *.schema.yaml | cut -d "." -f 1 | sed -e 's/\(.*\)/  - schema: \1/' >> default.yaml
}

build(){
  cd $pkgname-$_commit
  rime_deployer --build .
}

package() {
  cd $pkgname-$_commit
  find . -type l -delete
  rm {,build/}default.yaml user.yaml
  install -Dm644 *.yaml -t "$pkgdir"/usr/share/rime-data/
  install -Dm644 build/* -t "$pkgdir"/usr/share/rime-data/build/
}
